<? include("../../data/mysql.class.php")?>
<? include("../../data/Function.php")?>
<?
if(isset($_POST["Type"])){
    $Type=$_POST["Type"];
}else{
    $Type="error";
}


$conn=new Mysql();
switch($Type){
    case "delete":
        if($conn->query("delete from products where id =".$_POST["id"])){
            echo 1;
        }else{
            echo 0;
        }
        break;
    case "add":

        $type=$_POST["type"];
        $title=$_POST["title"];
        $title_f=$_POST["title_f"];
        $content=$_POST["content"];
        $content1=$_POST["content1"];
        $content2=$_POST["content2"];
        $adtitle=$_POST["adtitle"];
        $adkeyword=$_POST["adkeyword"];
        $adescription=$_POST["adescription"];
        $px=$_POST["px"];
        $ys_s_price=$_POST["ys_s_price"];
        $ys_e_price=$_POST["ys_e_price"];
        $pic1=$_POST["pic1"];
        $pic2=$_POST["pic2"];
        $is_hot=$_POST["is_hot"];
        $is_tejia=$_POST["is_tejia"];
        $styles=$_POST["styles"];
        $objects=$_POST["objects"];
        $con=new Mysql();
        $typestr="";

        if($conn->query("insert into products(type,typestr,title,title_f,content,content1,content2,ys_s_price,ys_e_price,styles,Linkcount,adate,pic,picall,Display_home,adtitle,adkeyword,adescription,px,is_hot,is_tejia,objects) values($type,'$typestr','$title','$title_f','$content','$content1','$content2','$ys_s_price','$ys_e_price','$styles',0,'".now()."','$pic1','$pic2',1,'$adtitle','$adkeyword','$adescription',$px,$is_hot,$is_tejia,'$objects')")){

            $rsid=$conn->lastId();
            $sql="update d_attr set pid=".$rsid." where shopid=0 and pid=0";
            $conn->query($sql);
            echo 1;}else{
           echo 0;
            // echo "insert into products(type,typestr,title,title_f,content,content1,content2,ys_s_price,ys_e_price,Linkcount,adate,pic,picall,Display_home,adtitle,adkeyword,adescription,px,is_hot,is_tejia) values($type,'$typestr','$title','$title_f','$content','$content1','$content2','$ys_s_price','$ys_e_price',0,'".now()."','$pic1','$pic2',1,'$adtitle','$adkeyword','$adescription',$px,$is_hot,$is_tejia)";
        }
        break;
    case "edit":
        $type=$_POST["type"];
        $title=$_POST["title"];
        $title_f=$_POST["title_f"];
        $content=$_POST["content"];
        $content1=$_POST["content1"];
        $content2=$_POST["content2"];
        $adtitle=$_POST["adtitle"];
        $adkeyword=$_POST["adkeyword"];
        $adescription=$_POST["adescription"];
        $px=$_POST["px"];
        $ys_s_price=$_POST["ys_s_price"];
        $ys_e_price=$_POST["ys_e_price"];
        $pic1=$_POST["pic1"];
        $pic2=$_POST["pic2"];
        $is_hot=$_POST["is_hot"];
        $is_tejia=$_POST["is_tejia"];
        $styles=$_POST["styles"];
        $objects=$_POST["objects"];
        $typestr="";
        $id=$_POST["id"];
        $conn=new Mysql();
        if($conn->query("update products set type=$type,title='$title',title_f='$title_f',content='$content',content1='$content1',content2='$content2',ys_s_price='$ys_s_price',ys_e_price='$ys_e_price',pic='$pic1',picall='$pic2',adtitle='$adtitle',adkeyword='$adkeyword',adescription='$adescription',px='$px',is_hot=$is_hot,is_tejia=$is_tejia,styles='$styles',objects='$objects' where id=".$id)){

            echo 1;}else{
           echo 0;
            // echo "update products set type=$type,title='$title',title_f='$title_f',content='$content',content1='$content1',content2='$content2',ys_s_price='$ys_s_price',ys_e_price='$ys_e_price',pic='$pic1',picall='$pic2',adtitle='$adtitle',adkeyword='$adkeyword',adescription='$adescription',px='$px',is_hot=$is_hot,is_tejia=$is_tejia where id=".$id;
        }
        break;
    case "checkstate":
        if($conn->query("update  products set Display_home=".$_POST["isstate"]." where id =".$_POST["id"])){
            echo 1;
        }else{
            echo 0;
        }
        break;
    default:
        break;
}
?>